import { createRouter, createWebHistory } from 'vue-router'
import SdyHome from '@/views/SdyHome/index.vue'
import SdyCart from '@/views/SdyCart/index.vue'
import SdyCate from '@/views/SdyCategory/index.vue'
import SdySelf from '@/views/SdySelf/index.vue'
import NotFound from '@/views/NotFound/index.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      redirect: '/home'
    },
    {
      path: '/home',
      name: 'home',
      component: SdyHome
    },
    {
      path: '/cate',
      name: 'cate',
      component: SdyCate
    },
    {
      path: '/cart',
      name: 'cart',
      component: SdyCart
    },
    {
      path: '/self',
      name: 'self',
      component: SdySelf
    },
    {
      path: '/list',
      name: 'list',
      component: () => import('@/views/SdyGoodsList/index.vue')
    },
    {
      path: '/search',
      name: 'search',
      component: () => import('@/views/SdySearch/index.vue'),
      meta: { hidFooter: true }
    },
    {
      // 找不到路由
      path: '/not-found',
      name: 'not-found',
      component: NotFound,
      meta: { hidFooter: true }
    },
    {
      // 匹配任意内容
      path: '/:pathMatch(.*)*',
      redirect: '/not-found'
    }
  ]
})

export default router
